import 'package:base_app/utils/permission_util.dart';
import 'package:flutter_contacts/flutter_contacts.dart';
import 'package:permission_handler/permission_handler.dart';

import 'base_handler.dart';

class ContactsHandler extends BaseHandler {

  @override
  String name = "contacts";

  @override
  void handler(dynamic data, dynamic responseCallback) async {
    bool permission = await PermissionUtil.getPermissionStatus(Permission.contacts);
    if(!permission) {
      return;
    }
    List<Contact> contacts = await FlutterContacts.getContacts(
        withProperties: true, withPhoto: true);
    for (var value in contacts) {
      print("${value.name}: ${value.displayName}: ${value.phones}");
    }
  }
}